/*******************************************************************************
 * Copyright (c) 2013 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package com.niannian.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import android.content.Context;
import android.util.DisplayMetrics;

public class DrawInfo {
	public static int sys_width = 0;
	public static int sys_height = 0;

	public static final int week_show_grid = 5;
	public static final int week_x_max_grid = 7;
	public static final int week_y_max_grid = 24;
	public static int week_grid_width = 0;
	public static int week_grid_height = 0;
	public static int week_xoffset = 40;
	public static int week_yoffset = 0;
	public static int week_title_height = 80;

	public static final int day_width_grid_num = 1;
	public static final int day_show_houre_num = 24;
	public static final int day_max_time_item = 24;
	public static final int day_show_time_item = 24;
	public static int day_grid_width;
	public static int day_grid_height;
	public static int day_left_width = 40;

	public static List<Map<String, Object>> courseList = new ArrayList<Map<String, Object>>();

	public static void measure(Context con) {
		DisplayMetrics dm = con.getResources().getDisplayMetrics();
		if (dm.widthPixels != sys_width && dm.heightPixels != sys_height) {
			sys_width = dm.widthPixels;
			sys_height = dm.heightPixels;
			measureWeek(sys_width, sys_height);
			measureDay(sys_width, sys_height);			
		}
	}

	public static void measureWeek(int width, int height) {
		week_xoffset = width / 12;
		week_grid_width = (int) Math.floor((width - week_xoffset) * 100 / week_show_grid);
		week_grid_width /= 100;
		week_grid_height = height / 10;
		week_xoffset = width - week_grid_width * week_show_grid;
		week_yoffset = 0;
		week_title_height = week_grid_height / 2;
	}

	public static void measureDay(int width, int height) {
		day_left_width = width / 12;
		day_grid_width = (int) Math.floor((width - day_left_width) * 100 / day_width_grid_num);
		day_grid_width /= 100;
		day_left_width = width - day_grid_width * day_width_grid_num;
		day_grid_height = height / 6;
	}
}
